package list

func reorderList(head *ListNode) {
	nodeList := []*ListNode{}

	if head == nil {
		return
	}

	for temp := head; temp != nil; temp = temp.Next {
		nodeList = append(nodeList, temp)
	}

	i, j := 0, len(nodeList)-1

	for i < j {
		nodeList[i].Next = nodeList[j]
		i++
		if i < j {
			nodeList[j].Next = nodeList[i]
			j--
		} else {
			nodeList[j].Next = nil
		}
	}

}
